﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BGM_Project_Expense.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.Form.BGM_Project_Expense" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <title><asp:Literal runat="Server" id="litTitle"/></title>
</head>
<body>
    <form id="form1" runat="server" class="defaultFont">
        <link rel="StyleSheet" href="../../Styles/StyleSheet.css" type="text/css">
        
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager> 
                
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None"  > 
        </telerik:RadAjaxLoadingPanel>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rblBgmExpGrpSeq">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="tView" />
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cmdSearch">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="tView" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="tView">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="dtgExpense">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="PanelEdit">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rblBgmExpGrpSeq" />
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cmdDelete">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rblBgmExpGrpSeq" />
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cmdCancel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rblBgmExpGrpSeq" />
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cmdUpdate">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rblBgmExpGrpSeq" />
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cmdInsert">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rblBgmExpGrpSeq" />
                        <telerik:AjaxUpdatedControl ControlID="dtgExpense" />
                        <telerik:AjaxUpdatedControl ControlID="PanelEdit" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>    
                
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                
            </script>
        </telerik:RadCodeBlock>

        <%--<div class="header-grid">
            <asp:Label ID="lblProjName" runat="server" />
        </div>--%>
        <asp:Label ID="lblRecordStatus" runat="server" visible="false" />
        <div class="DivBody" align="center">
            <asp:RadioButtonList ID="rblBgmExpGrpSeq" runat="server" RepeatDirection="Horizontal"
                DataTextField="Name" DataValueField="Sequence" AutoPostBack="true"
                OnSelectedIndexChanged="rblBgmExpGrpSeq_SelectedIndexChanged">
            </asp:RadioButtonList>
        </div>
        <table cellpadding="0" cellspacing="0">
            <tr valign="top">
                <td width="290px">
                    <div class="DivBody" style="border: 1px solid #999999;">
                        <table>
                            <tr>
                                <td>
                                    ค้นหา :
                                </td>
                                <td>
                                    <telerik:RadTextBox ID="txtSearch" runat="server" Width="180px" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="cmdSearch" runat="server" 
                                        ImageUrl="~/APP_UI/Image/Buttons/Magnifier.gif" OnClick="cmdSearch_Click" />
                                </td>
                            </tr>
                        </table>
                        <br />
                        <span style="color: #FF0000; font-weight: bold">&nbsp;&nbsp;เลือกค่าใช้จ่ายเพื่อบันทึกค่าใช้จ่ายโครงการ</span>
                        <br />
                        <br />
                        <telerik:RadTreeView ID="tView" 
                            runat="server" 
                            DataFieldID="bgm_exp_seq" 
                            DataValueField="bgm_exp_seq" 
                            DataFieldParentID="upper_bgm_exp_seq"
                            DataTextField="bgm_exp_name" 
                            OnNodeClick="tView_NodeClick"
                            MultipleSelect="false"
                            Height="410px"
                            Width="285px">
                            <%--<CollapseAnimation Duration="0" Type="None" />
                            <ExpandAnimation Duration="0" Type="None" />--%>
                        </telerik:RadTreeView>
                    </div>
                </td>
                <td width="10px">
                </td>
                <td>
                    <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="dtgExpense" runat="server" 
                        AllowMultiRowSelection="false" AutoGenerateColumns="False" Font-Names="Segoe UI" 
                        Font-Size="13px" GridLines="None" MasterTableView-GridLines="None" 
                        OnItemCommand="dtgExpense_ItemCommand"
                        Width="600px" Height="250px">
                        <mastertableview CommandItemDisplay="None" DataKeyNames="value" GroupLoadMode="Client"
                            NoDetailRecordsText="... ไม่มีข้อมูล ..." width="100%"><%----%>
                            <Columns>
                                <telerik:GridBoundColumn DataField="value" UniqueName="value" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="bgm_proj_exp_seq" UniqueName="bgm_proj_exp_seq" Visible="false">
                                </telerik:GridBoundColumn>
                                
                                <%--<telerik:GridEditCommandColumn ButtonType="ImageButton">
                                    <HeaderStyle Width="40px" />
                                    <ItemStyle Height="40px" HorizontalAlign="Center" />
                                </telerik:GridEditCommandColumn>--%>
                                <telerik:GridTemplateColumn UniqueName="edit" HeaderText="แก้ไข">
                                    <HeaderStyle Width="40px" />
                                    <ItemStyle Height="40px" HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:ImageButton ID="cmdEdit" runat="server" ImageUrl="~/APP_UI/Image/Grid/Edit.gif" CommandName="GridEdit" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                    CurrentFilterFunction="Contains" DataField="text" FilterControlWidth="100%" 
                                    HeaderStyle-HorizontalAlign="Center" HeaderText="ค่าใช้จ่าย" 
                                    ShowFilterIcon="false" UniqueName="text"
                                    ItemStyle-Width="500px">
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" 
                                    HeaderText="รายละเอียด" ItemStyle-HorizontalAlign="Left"
                                    UniqueName="descr"
                                    ItemStyle-Width="150px" ShowFilterIcon="false"
                                    FilterControlWidth="100%" >
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lbDescr" runat="server"
                                            Text='<%# Eval("descr").ToString().Replace("\r\n", "<br />") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn AllowFiltering="false"
                                    UniqueName="total_amount" 
                                    HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="100px" 
                                    HeaderText="จำนวนเงิน(บาท)" ItemStyle-HorizontalAlign="Right" 
                                    ItemStyle-Width="80px" ShowFilterIcon="false">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lbTotalAmount" runat="server"
                                            ForeColor="Blue" Text='<%# Eval("total_amount", "{0:n2}") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                
                                <%--<telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" 
                                    HeaderText="รหัสค่าใช้จ่าย" ItemStyle-HorizontalAlign="Left" 
                                    DataField="bgm_proj_exp_seq"
                                    UniqueName="bgm_proj_exp_seq" visible="false">
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                    CurrentFilterFunction="Contains" DataField="bgm_exp_grp_x" 
                                    FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                    HeaderText="ลักษณะการเบิกจ่าย" ShowFilterIcon="false" 
                                    UniqueName="bgm_exp_grp_x" Visible="false">
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="icm_res_item_seq"
                                    UniqueName="icm_res_item_seq" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="unit_price"
                                    UniqueName="unit_price" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="unit_qty"
                                    UniqueName="unit_qty" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="bgm_source_seq"
                                    UniqueName="bgm_source_seq" Visible="false">
                                </telerik:GridBoundColumn>--%>
                            </Columns>
                            <groupbyexpressions>
                                <telerik:GridGroupByExpression>
                                    <groupbyfields>
                                        <telerik:GridGroupByField FieldName="bgm_exp_seq_2" HeaderText="" />
                                    </groupbyfields>
                                    <selectfields>
                                        <telerik:GridGroupByField FieldName="bgm_exp_name_2" 
                                            HeaderText="หมวดค่าใช้จ่าย : " HeaderValueSeparator="" />
                                    </selectfields>
                                </telerik:GridGroupByExpression>
                                <telerik:GridGroupByExpression>
                                    <groupbyfields>
                                        <telerik:GridGroupByField FieldName="bgm_exp_seq_1" HeaderText="" />
                                    </groupbyfields>
                                    <selectfields>
                                        <telerik:GridGroupByField FieldName="bgm_exp_name_1" 
                                            HeaderText="รายการรายจ่าย : " HeaderValueSeparator="" />
                                    </selectfields>
                                </telerik:GridGroupByExpression>
                            </groupbyexpressions>
                        </mastertableview>
                        <clientsettings EnableRowHoverStyle="true" >
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                            <selecting AllowRowSelect="false" />
                        </clientsettings>
                    </telerik:RadGrid>
                    <div class="DivBody" style="border: 1px solid #999999; margin-top: 10px;">
                        <asp:Panel ID="PanelEdit" runat="server">
                            <table>
                                <tr>
                                    <td width="120px">
                                        หมวดรายจ่าย :
                                    </td>
                                    <td>
                                        <asp:Label ID="lblBgmProjExpSeq" runat="server" Visible="false" />
                                        <asp:Label ID="lblBgmProjSeq" runat="server" Visible="false" />
                                        <asp:Label ID="lblBgmSourceSeq" runat="server" Visible="false" />
                                        <asp:Label ID="lblBgmExpSeq" runat="server" Visible="false" />
                                        <asp:Label ID="lblBgmExpGrpSeqReal" runat="server" Visible="false" />
                                        <asp:Label ID="lblBgmExpName3" runat="server" ForeColor="Blue" />
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td width="120px">
                                        รายการค่าใช้จ่าย :
                                    </td>
                                    <td>
                                        <asp:Label ID="lblBgmExpName2" runat="server" ForeColor="Blue" />
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td width="120px">
                                        ค่าใช้จ่าย :
                                    </td>
                                    <td>
                                        <asp:Label ID="lblBgmExpName1" runat="server" ForeColor="Blue" />
                                    </td>
                                </tr>
                            </table>
                            <asp:Panel ID="PanelInv" runat="server" BorderColor="#003399" width="570px"
                                BorderStyle="Solid" BorderWidth="2px" style="margin-top: 10px; margin-bottom: 10px">
                                <div class="DivInfo">
                                    <table>
                                        <tr>
                                            <td width="110px">
                                                รายการพัสดุ :
                                            </td>
                                            <td>
                                                <telerik:RadComboBox ID="ddlResourceSubGroup" runat="server"
                                                    DataTextField="icm_res_item_name" DataValueField="icm_res_item_seq"
                                                    Width="400px" />&nbsp;*
                                            </td>
                                        </tr>
                                    </table>
                                    <table>
                                        <tr>
                                            <td width="110px">
                                                จำนวนหน่วย :</td>
                                            <td>
                                                <telerik:RadNumericTextBox ID="txtUnitQty" runat="server" MinValue="0" 
                                                    AutoPostBack="true" OnTextChanged="txtUnitQty_TextChanged"  />&nbsp;*
                                            </td>
                                        </tr>
                                    </table>
                                    <table>
                                        <tr>
                                            <td width="110px">
                                                จำนวนเงินต่อหน่วย :
                                            </td>
                                            <td>
                                                <telerik:RadNumericTextBox ID="txtUnitPrice" runat="server" MinValue="0" 
                                                    AutoPostBack="true" OnTextChanged="txtUnitPrice_TextChanged" />
                                            </td>
                                            <td>
                                                &nbsp;บาท *
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </asp:Panel>
                            <table>
                                <tr>
                                    <td width="120px">
                                        จำนวนเงิน :
                                    </td>
                                    <td>
                                        <telerik:RadNumericTextBox ID="txtTotalAmount" runat="server" MinValue="0"  />
                                    </td>
                                    <td>
                                        &nbsp;บาท *
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td width="120px" valign="top">
                                        คำอธิบาย :</td>
                                    <td>
                                        <telerik:RadTextBox ID="txtDescr" runat="server" TextMode="MultiLine" 
                                            Width="450px" Height="50px" />
                                    </td>
                                </tr>
                            </table>
                            <table width="100%">
                                <tr>
                                    <td align="center">
                                        <asp:Button ID="cmdInsert" runat="server" Text="บันทึก" Width="120px" 
                                            OnClick="cmdInsert_Click" />
                                        <asp:Button ID="cmdUpdate" runat="server" Text="บันทึก" Width="120px" 
                                            OnClick="cmdUpdate_Click" Visible="False" />
                                        &nbsp;
                                        <asp:Button ID="cmdCancel" runat="server" Text="การยกเลิกการแก้ไข" 
                                            Width="120px" OnClick="cmdCancel_Click" Visible="False" />
                                        &nbsp;
                                        <asp:Button ID="cmdDelete" runat="server" Text="ลบรายการ" 
                                            Width="120px" OnClick="cmdDelete_Click" Visible="False" />
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                    </div>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
